// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.randomizedWorld.randomizedDeadSurvivor;

import java.util.ArrayList;
import zombie.characters.IsoPlayer;
import zombie.core.Rand;
import zombie.iso.BuildingDef;
import zombie.iso.RoomDef;
import zombie.network.GameClient;
import zombie.network.GameServer;

public final class RDSHouseParty extends RandomizedDeadSurvivorBase {
    final ArrayList<String> items = new ArrayList();

    public RDSHouseParty() {
        this.name = "House Party";
        this.setChance(4);
        this.items.add("Base.Crisps");
        this.items.add("Base.Crisps2");
        this.items.add("Base.Crisps3");
        this.items.add("Base.Pop");
        this.items.add("Base.Pop2");
        this.items.add("Base.Pop3");
        this.items.add("Base.Cupcake");
        this.items.add("Base.Cupcake");
        this.items.add("Base.CakeSlice");
        this.items.add("Base.CakeSlice");
        this.items.add("Base.CakeSlice");
        this.items.add("Base.CakeSlice");
        this.items.add("Base.CakeSlice");
    }

    @Override
    public boolean isValid(BuildingDef def, boolean force) {
        this.debugLine = "";
        if (GameClient.bClient) {
            return false;
        } else if (def.isAllExplored() && !force) {
            return false;
        } else {
            if (!force) {
                for (int _int = 0; _int < GameServer.Players.size(); _int++) {
                    IsoPlayer isoPlayer = (IsoPlayer)GameServer.Players.get(_int);
                    if (isoPlayer.getSquare() != null && isoPlayer.getSquare().getBuilding() != null && isoPlayer.getSquare().getBuilding().def == def) {
                        return false;
                    }
                }
            }

            if (this.getRoom(def, "livingroom") != null) {
                return true;
            } else {
                this.debugLine = "No living room";
                return false;
            }
        }
    }

    @Override
    public void randomizeDeadSurvivor(BuildingDef def) {
        RoomDef roomDef = this.getRoom(def, "livingroom");
        this.addZombies(def, Rand.Next(5, 8), "Party", null, roomDef);
        this.addRandomItemsOnGround(roomDef, this.items, Rand.Next(4, 7));
        def.bAlarmed = false;
    }
}
